package day09.task;

import java.util.Scanner;

public abstract class Operation {
    private double numberA;
    private double numberB;

            public Operation(int numberA, int numberB) {
        this.numberA = numberA;
        this.numberB = numberB;
    }

    public double getNumberA() {
        return numberA;
    }

    public void setNumberA(int numberA) {
        this.numberA = numberA;
    }

    public double getNumberB() {
        return numberB;
    }

    public void setNumberB(int numberB) {
        this.numberB = numberB;
    }

    public abstract void getResult();
}

class OpeartionAdd extends Operation {
    public OpeartionAdd(int numberA, int numberB) {
        super(numberA, numberB);
    }

    @Override
    public void getResult() {
        System.out.println("运算结果为：" + (getNumberA() + getNumberB()));
    }
}

class OpeartionDelete extends Operation {
    public OpeartionDelete(int numberA, int numberB) {
        super(numberA, numberB);
    }

    @Override
    public void getResult() {
        System.out.println("运算结果为：" + (getNumberA() - getNumberB()));
    }
}

class OpeartionMultiply extends Operation {
    public OpeartionMultiply(int numberA, int numberB) {
        super(numberA, numberB);
    }

    @Override
    public void getResult() {
        System.out.println("运算结果为：" + (getNumberA() * getNumberB()));
    }
}

class OpeartionDivide extends Operation {
    public OpeartionDivide(int numberA, int numberB) {
        super(numberA, numberB);
    }

    @Override
    public void getResult() {
        System.out.println("运算结果为：" + (getNumberA() / getNumberB()));
    }
}

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("测试一下");
        boolean flag = true;
        while (flag == true) {
            System.out.println("请输入算术运算符符号+ - * / exit为退出：");
            String s = sc.next();
            Operation operation = null;
            if (s.equals("+")) {
                operation = new OpeartionAdd(sc.nextInt(), sc.nextInt());
                operation.getResult();
            } else if (s.equals("-")) {
                new OpeartionDelete(sc.nextInt(), sc.nextInt()).getResult();
            } else if (s.equals("*")) {
                new OpeartionMultiply(sc.nextInt(), sc.nextInt()).getResult();
            } else if (s.equals("/")) {
                new OpeartionDivide(sc.nextInt(), sc.nextInt()).getResult();
            } else if (s.equals("exit")) {
                System.out.println("退出程序");
                flag = false;
            } else {
                System.out.println("运算符输入错误，请重新输入：");
            }
            operation.getResult();
        }
    }
}
